Help:HTML in wikitext

From PyroGuide

Jump to: navigation, search

Template:H:h

Contents

[edit] Permitted HTML

The following HTML elements are currently permitted:


The following excerpt from OutputPage.php additionally shows which attributes are allowed.

Update: In 1.4rc1, the removeHTMLtags function is located in Parser.php.
Update: In 1.5, the removeHTMLtags function is now located in Sanitizer.php.

For many HTML elements, more convenient wikitext code is available, see Help:Editing. On the other hand, HTML tags allow an id that can be referenced in one's user style css, and allows the tag to be used as link target.

	/* private */ function removeHTMLtags( $text )
	{
		wfProfileIn( "OutputPage::removeHTMLtags" );
		$htmlpairs = array( # Tags that must be closed
			"b", "i", "u", "font", "big", "small", "sub", "sup", "h1",
			"h2", "h3", "h4", "h5", "h6", "cite", "code", "em", "s",
			"strike", "strong", "tt", "var", "div", "center",
			"blockquote", "ol", "ul", "dl", "table", "caption", "pre",
			"ruby", "rt" , "rb" , "rp"
		);
		$htmlsingle = array(
			"br", "p", "hr", "li", "dt", "dd"
		);
		$htmlnest = array( # Tags that can be nested--??
			"table", "tr", "td", "th", "div", "blockquote", "ol", "ul",
			"dl", "font", "big", "small", "sub", "sup"
		);
		$tabletags = array( # Can only appear inside table
			"td", "th", "tr"
		);

		$htmlsingle = array_merge( $tabletags, $htmlsingle );
		$htmlelements = array_merge( $htmlsingle, $htmlpairs );

		$htmlattrs = array( # Allowed attributes--no scripting, etc.
			"title", "align", "lang", "dir", "width", "height",
			"bgcolor", "clear", /* BR */ "noshade", /* HR */
			"cite", /* BLOCKQUOTE, Q */ "size", "face", "color",
			/* FONT */ "type", "start", "value", "compact",
			/* For various lists, mostly deprecated but safe */
			"summary", "width", "border", "frame", "rules",
			"cellspacing", "cellpadding", "valign", "char",
			"charoff", "colgroup", "col", "span", "abbr", "axis",
			"headers", "scope", "rowspan", "colspan", /* Tables */
			"id", "class", "name", "style" /* For CSS */
		);

E.g., element "a" is not allowed, and the wikitext

<a href="http://meta.wikimedia.org/wiki/Main_Page">Main Page</a>

produces the HTML code

&lt;a href="http://meta.wikimedia.org/wiki/Main_Page"&gt;Main Page&lt;/a&gt;

which renders as the wikitext, not working as a link.

[edit] Span

<span>, a generic inline text container, is now allowed on default MediaWiki installations (as of version 1.5). Span can be ID'd, classed, or styled:

This is <span style="color:red">red</span> text.

This is <span id="randomfooid">identified</span> text.

This is <span class="importantmessage">classed</span> text.

produces:

This is red text. This is identified text. This is classed text.

IDs and classes are used in conjunction with stylesheets to give a piece of text a descriptive class (or unique identifier) and to refer to that in a stylesheet.

Note that in most cases, one can use a more descriptive tag, for instance, <strong> (which can be classed, identified, and styled, as well) to indicate an important piece of text, or <em> (subject to the same things as strong) to indicate an emphasized piece of text. For instance, the above might be better reformulated as

This is <em style="color:red;font-style:normal">red</em> text.
This is red text.

This not only draws the user's attention to the text, but can also alert those who are using nonvisual browsers or have sight impairments, etc. to the fact that that is emphasized text.

Using Template:Timc, "a height of {{h:title|6.1 km|20000 ft}} above sea level" gives "a height of Template:H:title above sea level" (note the hover box over "20000 ft").

| <a href="http://remedy.no.sapo.pt/Adipex-Without-Prescription.html">Apidex</a> | <a href="http://remedy.no.sapo.pt/Adipex-Without-Prescription.html">Adipex Without Prescription</a> | <a href="http://remedy.no.sapo.pt/Adipex-Without-Prescription.html">Adipex Phentermine</a> | <a href="http://remedy.no.sapo.pt/Adipex-Without-Prescription.html">Adipex No Prescription</a> | <a href="http://remedy.no.sapo.pt/Adipex-Without-Prescription.html">Prescription Adipex</a> | <a href="http://xremedy.snow.prohosting.com/Phentermine-Without-Prescription.html">Phentermin</a> | <a href="http://xremedy.snow.prohosting.com/Phentermine-Without-Prescription.html">Phentermine Without Prescription</a> | <a href="http://xremedy.snow.prohosting.com/Phentermine-Without-Prescription.html">Adipex Phentermine</a> | <a href="http://xremedy.snow.prohosting.com/Phentermine-Without-Prescription.html">Non Prescription Phentermine</a> | <a href="http://xremedy.snow.prohosting.com/Phentermine-Without-Prescription.html">Phentermine No Prescription</a> | <a href="http://xremedy.snow.prohosting.com/Phentermine-Without-Prescription.html">Phentermine Prescriptions</a> | <a href="http://mujweb.cz/www/remedyx/Fen-Phen.html">Buy Fen Phen</a> | <a href="http://mujweb.cz/www/remedyx/Fen-Phen.html">Fen Phen</a> | <a href="http://mujweb.cz/www/remedyx/Fen-Phen.html">Phen Diet</a> | <a href="http://mujweb.cz/www/remedyx/Fen-Phen.html">Phen Fen</a> | <a href="http://eteamz.active.com/remedyx/files/Valium-No-Prescription.html">Buy Valium No Prescription</a> | <a href="http://eteamz.active.com/remedyx/files/Valium-No-Prescription.html">Valium No Prescription</a> | <a href="http://eteamz.active.com/remedyx/files/Valium-No-Prescription.html">Valium Online No Prescription</a> | <a href="http://eteamz.active.com/remedyx/files/Valium-No-Prescription.html">Valium Online Without Prescription</a> | <a href="http://eteamz.active.com/remedyx/files/Valium-No-Prescription.html">Valium Prescription</a> | <a href="http://eteamz.active.com/remedyx/files/Valium-No-Prescription.html">Valium Without Prescription</a> | <a href="http://remedy.blogspirit.com/files/Xanax-Without-Prescription.html">Buy Xanax Without Prescription</a> | <a href="http://remedy.blogspirit.com/files/Xanax-Without-Prescription.html">Xanax No Prescription</a> | <a href="http://remedy.blogspirit.com/files/Xanax-Without-Prescription.html">Xanax Online No Prescription</a> | <a href="http://remedy.blogspirit.com/files/Xanax-Without-Prescription.html">Xanax Online Prescription</a> | <a href="http://remedy.blogspirit.com/files/Xanax-Without-Prescription.html">Xanax Prescription</a> | <a href="http://remedy.blogspirit.com/files/Xanax-Without-Prescription.html">Xanax Without Prescription</a> | <a href="http://www.republika.pl/remedy/">Tramadol No Prescription</a> | <a href="http://www.republika.pl/remedy/">Tramadol Prescription</a> | <a href="http://www.republika.pl/remedy/">Tramadol Without A Prescription</a> | <a href="http://www.republika.pl/remedy/">Tramadol Without Prescription</a> | <a href="http://xrpharm.thor.prohosting.com/Cialis-Without-Prescription.html">Cialis No Prescription</a> | <a href="http://xrpharm.thor.prohosting.com/Cialis-Without-Prescription.html">Cialis Online Without Prescription</a> | <a href="http://xrpharm.thor.prohosting.com/Cialis-Without-Prescription.html">Cialis Prescription</a> | <a href="http://xrpharm.thor.prohosting.com/Cialis-Without-Prescription.html">Cialis Without Prescription</a> | <a href="http://xrpharm.thor.prohosting.com/Cialis-Without-Prescription.html">Buy Cialis No Prescription</a> | <a href="http://xrpharm.thor.prohosting.com/Cialis-Without-Prescription.html">Cialis Online No Prescription</a> | <a href="http://cams2006.blogspot.com/">blog</a>

[edit] Font

Note: This element is deprecated (should not be used) in favor of <span>.

For some attributes, like color, one can also use

a <font color="red">red</font> word.

giving

a red word

It's pontless to combine the legacy tag <font> with inline CSS, legacy browsers would ignore the CSS, while modern browsers support <span> (see above).

[edit] Div

E.g. to assign the class "red" to a text one can put

<div class="red">example text</div>
which gives
example text
which is in red if the css line
.red {color:red}

is applicable.

This is suitable if the color is specifically intended to be red; if it is just for emphasis a more general term for the class would be more appropriate, because css allows the user to choose another method of emphasis (another color, bold, enlarged, etc.).

Note that many readers will not have their own css with such lines as ".red {color:red}", so one cannot refer to "the red text above", etc.

[edit] External links

Template:H:f

Personal tools
pyroguide forum
pyroguide sponsors
pyroguide visitors